Previous Book Contents Book Index Next

Inside Macintosh: QuickTime /
Chapter 2 - Movie Toolbox / Movie Toolbox Reference
Functions That Modify Movie Properties / Working With Media Samples


MediaTimeToSampleNum

The MediaTimeToSampleNum function allows you to find the sample that contains the data for a specified time. You indicate the time in the media's time scale.

pascal void MediaTimeToSampleNum (Media theMedia, TimeValue time, 
                                 long *sampleNum, 
                                 TimeValue *sampleTime,
                                 TimeValue *sampleDuration);
theMedia
Specifies the media for this operation. You obtain this media identifier from such Movie Toolbox functions as NewTrackMedia and GetTrackMedia (described on page 2-138 and page 2-190, respectively).
time
Specifies the time for which you are retrieving sample information. You must specify this value in the media's time scale.
sampleNum
Contains a pointer to a long integer that is to receive the sample number. The Movie Toolbox returns the sample number that identifies the sample that contains data for the time specified by the time parameter.
sampleTime
Contains a pointer to a time value. The MediaTimeToSampleNum function updates this time value to indicate the starting time of the sample that contains data for the time specified by the time parameter. This time value is expressed in the media's time scale. Set this parameter to nil if you do not want this information.
sampleDuration
Contains a pointer to a time value. The Movie Toolbox returns the duration of the sample that contains data for the time specified by the time parameter. This time value is expressed in the media's time scale. Set this parameter to nil if you do not want this information.
DESCRIPTION
The Movie Toolbox returns information about the sample that contains data for that time, including its starting time, duration, and sample number.

The MediaTimeToSampleNum function does not account for edits applied to the media by a movie's tracks. If you want to work with edits, use the functions that allow you to look for interesting times. These functions are described in "Finding Interesting Times," beginning on page 2-180.

ERROR CODES
invalidMedia-2008This media is corrupted or invalid
SEE ALSO
You can convert a sample number into a time in a media's time scale by calling the SampleNumToMediaTime function, which is described in the next section.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996